/*
 * @Author: maomao
 * @Date: 2021-04-19 09:44:39
 * @Description: 
 * @FilePath: \client-app\src\router\index.ts
 */
import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from "vue-router";

// import defaultLayout from "@/layouts/dictionaries-toobar.vue";
import defaultLayout from "@/layouts/side-nav-inner-toolbar.vue";
import simpleLayout from "@/layouts/single-card.vue";
import blank from "@/layouts/blank.vue";

function loadView(view) {
    return () => import(/* webpackChunkName: "index" */ `@/views/${view}.vue`);
}

const routes: Array<RouteRecordRaw> = [
    {
        path: "/storeroom",
        name: "storeroom",
        meta: {
            requiresAuth: true,
            layout: blank
        },
        component: loadView("storeroom/storeroom")
    },
    {
        path: "/store-length",
        name: "store-length",
        meta: {
            requiresAuth: true,
            layout: blank
        },
        component: loadView("storeroom/store-length")
    },
    {
        path: "/drug",
        name: "drug",
        meta: {
            requiresAuth: true,
            layout: blank
        },
        component: loadView("drug/drug")
    },
    //对应处方设置
    {
        path: "/drug-corresponding-prescription",
        name: "drug-corresponding-prescription",
        meta: {
            requiresAuth: true,
            layout: blank
        },
        component: loadView("drug-corresponding-prescription/drug-corresponding-prescription")
         
    },
    //发药规则设置
    {
        path: "/dispensing-rules",
        name: "dispensing-rules",
        meta: {
            requiresAuth: true,
            layout: blank
        },
        component: loadView("dispensing-rules/dispensing-rules")
    },
     //厂牌供应
     {
        path: "/label-supply",
        name: "label-supply",
        meta: {
            requiresAuth: true,
            layout: blank
        },
        component: loadView("label-supply/label-supply")
    },
    //客户账号管理路由
    {
        path: "/index",
        name: "index",
        meta: {
            requiresAuth: true,
            layout: defaultLayout
        },
        component: loadView("index")
    },
    //客户账号管理路由
    {
        path: "/profile",
        name: "profile",
        meta: {
            requiresAuth: true,
            layout: defaultLayout
        },
        component: loadView("profile")
    },
    //示例 账号密码登录
    {
        path: "/login",
        name: "login",
        meta: {
            requiresAuth: false,
            layout: simpleLayout,
            title: ""
        },
        component: loadView("login/index")
    },
    // 重置密码
    {
        path: "/reset-password",
        name: "reset-password",
        meta: {
            requiresAuth: false,
            layout: simpleLayout,
            title: "",
            description:
                ""
        },
        component: loadView("reset-password-form")
    },
    // 手机号登录
    {
        path: "/login/phone",
        name: "phone",
        meta: {
            requiresAuth: false,
            layout: simpleLayout,
            title: "",
            description:
                ""
        },
        component: loadView("login/phone")
    },
    {
        path: "/create-account",
        name: "create-account",
        meta: {
            requiresAuth: false,
            layout: simpleLayout,
            title: "登录"
        },
        component: loadView("create-account-form")
    },
    {
        path: "/change-password/:recoveryCode",
        name: "change-password",
        meta: {
            requiresAuth: false,
            layout: simpleLayout,
            title: "更改密码"
        },
        component: loadView("change-password-form")
    },
    {
        path: "/refresh",
        name: "refresh",
        component: loadView("refresh")
    },
    {
        path: "/",
        redirect: "/drug"
    },
    {
        path: "/recovery",
        redirect: "/drug"
    },
    {
        path: "/:pathMatch(.*)*",
        redirect: "/drug"
    }
];

const router = createRouter({
    routes: routes,
    history: createWebHistory(),
});

export default router;
